import { appFriendFetch, dingtalkOApiFetch } from '../fetch';

const appFriend = appFriendFetch();
const dingtalkApi = dingtalkOApiFetch();
/**
 * 根据钉钉姓名列表获取钉钉用户id列表
 * @param data 姓名列表
 * @returns 钉钉用户id列表
 */
export const queryDingTalkIdByUserNames = (data: { userNames: string[] }) => {
  return appFriend.post<DingtalkUserInfo[]>('/smartApi/user/queryDingTalkIdByUserNames', data);
};
/**
 * 发送钉钉工作通知
 * @param params url上拼接的参数
 * @param data 请求数据
 * @returns 结果
 */
export const asyncsendV2 = (params: { access_token: string }, data: any): Promise<DingtalkResponseType> => {
  return dingtalkApi.post('/topapi/message/corpconversation/asyncsend_v2', data, { params });
};
/**
 * 发送到钉钉机器人
 * @param params url上拼接的参数
 * @param data 请求数据
 * @returns 结果
 */
export const sendToRobot = (params: { access_token: string; sign: string; timestamp: number }, data: any): Promise<DingtalkResponseType> => {
  return dingtalkApi.post('/robot/send', data, { params });
};
